package io.qytc.jboot.utils;

import com.alibaba.fastjson.JSONObject;

public class StrVaildatorUtils {

    public static final String REGEX_MOBILE = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$";

    /**
     * 检验字符串是否为json格式
     * @param str
     * @return
     */
    public static boolean isJson(String str) {
        try {
            JSONObject.parseObject(str);
            return true;
        } catch (Exception e) {
            return false;
        }
    }

    public static boolean isMobile(String phone){
        if (phone.matches(REGEX_MOBILE)) {
            return true;
        } else {
            return false;
        }
    }
}
